package com.kidedu.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class FileDispose{
	
	public String fileUpload(File upload, String url) throws Exception{
		if (upload != null){
			FileOutputStream fos = new FileOutputStream(url);
			FileInputStream fis = new FileInputStream(upload);
			byte[] buffer = new byte[1024];
			int len = 0;
			while ((len = fis.read(buffer))>0){
				fos.write(buffer, 0, len);
			}
			fis.close();
			fos.close();
			return "success";
		}
		else{
			return "error";
		}
	}
	
	public boolean deleteFile(String url){
		boolean flag = false;  
		File file = new File(url);  
	    if (file.isFile() && file.exists()) {  
	        file.delete();  
	        flag = true;  
	    }  
	    return flag;  
	}
	
}